﻿using Bootstrap.Security.Authorization;
using System;

namespace Microsoft.Extensions.DependencyInjection
{
    /// <summary>
    /// 按钮授权服务扩展类
    /// </summary>
    public static class ButtonAuthorizationServicesCollectionExtensions
    {
        /// <summary>
        /// 添加按钮授权服务到服务容器中
        /// </summary>
        /// <param name="services">容器服务集合</param>
        /// <param name="func">通过用户名获取授权按钮集合回调方法(userName, url, auths) => bool</param>
        /// <returns>容器服务集合</returns>
        public static IServiceCollection AddButtonAuthorization(this IServiceCollection services, Func<string, string, string, bool> func = null)
        {
            services.AddSingleton<IButtonAuthorization>(new DefaultButtonAuthorization(func));
            return services;
        }
    }
}
